package top.zhimingw.service.impl;

import org.springframework.stereotype.Service;
import top.zhimingw.pojo.Front;
import top.zhimingw.redis.AdminKey;
import top.zhimingw.service.BaseService;
import top.zhimingw.service.FrontService;

/**
 * @ClassName FrontServiceImpl
 * @Description (Front)表服务实现类
 * @Author:zhimingw
 * @Version 1.0
 * @since 2021/6/1 16:52
 */
@Service("frontService")
public class FrontServiceImpl extends BaseService implements FrontService {
    /**
    * @Description: 查询单条数据
    * @Param: [id]
    * @return: top.zhimingw.pojo.Front
    * @Author: zhimingw
    * @Date: 2021/6/1
    */
    @Override
    public Front queryById(Integer id) {
        Front front = null;
        if(redisService.exists(AdminKey.getByFront,String.valueOf(id))){
            front = redisService.get(AdminKey.getByFront,String.valueOf(id),Front.class);
        }else{
            front = frontMapper.queryById(id);
            redisService.set(AdminKey.getByFront,String.valueOf(id),front,60*60*24);
        }
        return front;
    }

    /**
    * @Description: 修改数据，哪个属性不为空就修改哪个属性
    * @Param: [front]
    * @return: boolean
    * @Author: zhimingw
    * @Date: 2021/6/1
    */
    @Override
    public boolean update(Front front) {
        if(frontMapper.update(front)==1){
            return true;
        }
        return false;
    }
}
